<template>
  <div class="step3">
    <van-field v-model="password" label="密码" placeholder="请输入密码"/>
    <van-button
      round
      block
      @click="dofinishregisterFN"
      :disabled="!flag"
      color="#ff6666"
      style="margin-top: 20px">注册
    </van-button>
  </div>
</template>

<script>
import Vue from 'vue'
import {
  Field,
  Button
} from 'vant'

import { dofinishregister } from '@/api/register'

Vue.use(Field)
Vue.use(Button)

export default {
  name: 'step3',
  data () {
    return {
      password: '123@QQ.com'
    }
  },
  computed: {
    flag () {
      return /^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])(?=\S*[!@#$%^&*? ])\S*$/.test(this.password)
    }
  },
  methods: {
    dofinishregisterFN () {
      dofinishregister({ tel: localStorage.getItem('tel'), password: this.password }).then(res => {
        console.log(res.data)
        console.log(localStorage.getItem('tel'))
        if (res.data.code === '200') {
          // localStorage.removeItem('tel')
          // this.$router.go(-3)
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
